<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>倒计时</title>
  <style type="text/css">
*{margin:0;padding:0;list-style:none;}

  </style>
  <script type="text/javascript" src="jquery-1.11.3.min.js"></script>
</head>
<body>
<div class="time" id="time"></div>
<div class="gk">距高考还有： <span id="gk"></span> 天</div>
<div class="hd">距活动结束还有： <span id="hd"></span></div>
<script type="text/javascript">
//获取当前系统时间
window.onload= function(){
showtime();qgtime();
}
function checktime(i){
	if (i<10) {
	i="0"+i;
	}
	return i;
}
function showtime(){
  		var MyDate = new Date(),
	  	year = MyDate.getFullYear(),
	  	month = MyDate.getMonth()+1,
	  	date = MyDate.getDate(),
	  	week = MyDate.getDay(),
	  	h = MyDate.getHours(),
	  	m = MyDate.getMinutes(),
	  	s = MyDate.getSeconds();
	  	m = checktime(m);
	  	s = checktime(s);
	  	var weekday = new Array(7)
		  	weekday[0]="星期日  "
		  	weekday[1]="星期一  "
		  	weekday[2]="星期二  "
		  	weekday[3]="星期三  "
		  	weekday[4]="星期四  "
		  	weekday[5]="星期五  "
		  	weekday[6]="星期六  "
  	document.getElementById('time').innerHTML=year+'年'+month+'月'+date+'日  ' + weekday[week]+ h+":"+m+":"+s;
  	setTimeout(showtime,1000);
  	}


//日期倒计时
var curtime = new Date(),
	endtime = new Date("2017,6,6"),
	lefttime = Math.ceil((endtime.getTime() - curtime.getTime())/(24*60*60*1000));
	document.getElementById('gk').innerHTML=lefttime;

//抢购倒计时

	function qgtime(){
	var sttime = new Date(),
	entime = new Date("2016/12/14,11:20:00"),
	ctime =parseInt((entime.getTime() - sttime.getTime())/1000),
	d = parseInt(ctime/(60*60*24)),
	h = parseInt(ctime/(60*60)%24),
	m = parseInt(ctime/60%60),
	s = ctime%60;
	if (ctime<=0) {
		document.getElementById('hd').innerHTML="活动已结束";
	}else{
	document.getElementById('hd').innerHTML=d+" 天 "+h+" 小时 "+m+" 分 "+s+" 秒";
	}
	setTimeout(qgtime,1000);
	}
</script>
</body>
</html>
